home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / CommToolbox (modified) / Sources / CCTBApp.cp < prev    next >
Encoding:
Text File  |  1994-11-30  |  4.4 KB  |  213 lines  |  [TEXT/KAHL]

  1. /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2.  
  3.     CCTBApp.c
  4.     
  5.     CommToolbox compatible application class.
  6.     
  7.     SUPERCLASS = CApplication.
  8.     
  9.     Original copyright © 1992-93 Romain Vignes. All rights reserved.
  10.     Modifications copyright © 1994-95 Ithran Einhorn. All rights reserved.
  11.     
  12. ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
  13.  
  14.  
  15. #include <CommResources.h>                    /* Apple includes */
  16.  
  17. #include <CError.h>                            /* TCL includes */
  18. #include <Global.h>
  19. #include <OSChecks.h>
  20.  
  21. #ifdef __USETHREADS__
  22.     #include "CThread.h"                    /* Thread Manager */
  23. #endif
  24.  
  25. #include "CConnection.h"                    /* Other includes */
  26. #include "CCTBApp.h"
  27. #include "CCTBDesktop.h"
  28. #include "CCTBSwitchboard.h"
  29. #include "CFileTransfer.h"
  30. #include "CTermPane.h"
  31.  
  32. /* Constantes & Macros */
  33.  
  34. #define ERR_STR_ID            2000    /* Error messages ID */
  35. #define CTB_STR_INDEX        1        /* CTB message */
  36.  
  37. #define MIN_CTB_VERS        0x100    /* Minimum CommToolbox version */
  38.  
  39. #define CTB_TRAP            0x8B    /* CommToolbox trap */
  40.  
  41.  
  42. /* Variables globales */
  43.  
  44. extern tSystem    gSystem;
  45. extern CDesktop    *gDesktop;
  46. extern CError    *gError;
  47.  
  48.  
  49. /*
  50.  * ICTBApp
  51.  *
  52.  * Initialize the CTBApp object
  53.  *
  54.  * extraMasters:        Number of extra blocks
  55.  * aRainyDayFund:        Bytes of memory to reserve
  56.  * aCriticalBalance:    Bytes of memory to reserve for a critical operation    
  57.  * aToolboxBalance:        Bytes to save for the toolbox
  58.  *
  59.  */
  60.  
  61. void CCTBApp::ICTBApp(short extraMasters, Size aRainyDayFund,
  62.                       Size aCriticalBalance, Size aToolboxBalance)
  63. {
  64. #ifdef __USETHREADS__
  65.     threadManagerPresent = CThread::cIsPresent();
  66. #endif
  67.  
  68.     inherited::IApplication(extraMasters,aRainyDayFund,aCriticalBalance,
  69.                             aToolboxBalance); /* Initialize superclass */
  70.                                 
  71.     CApplication::cMaxSleepTime = 0L;
  72.     
  73.     if (!managersPresent())    {        /* CommToolbox installed ? */
  74.         SysBeep(3);
  75.         gError->PostAlert(ERR_STR_ID,CTB_STR_INDEX);
  76.         this->Exit();
  77.         ExitToShell();
  78.     }
  79.     
  80.     InitCRM();                /* CTB managers initialization */
  81.     InitCTBUtilities();
  82.     CConnection::cInitManager();
  83.     CTermPane::cInitManager();
  84.     CFileTransfer::cInitManager();
  85. }
  86.  
  87.  
  88. /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
  89.  
  90. /*
  91.  * MakeDesktop
  92.  *
  93.  * CommToolbox desktop initialization
  94.  *
  95.  */
  96.  
  97. void CCTBApp::MakeDesktop(void)
  98. {
  99.     gDesktop = new(CCTBDesktop);    
  100.             
  101.     ((CCTBDesktop *)gDesktop)->ICTBDesktop(this);
  102. }    
  103.  
  104.  
  105. /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
  106.  
  107. /*
  108.  * MakeSwitchboard
  109.  *
  110.  * CommToolbox switchboard initialization
  111.  *
  112.  */
  113.  
  114. void CCTBApp::MakeSwitchboard(void)
  115. {
  116.     itsSwitchboard = new(CCTBSwitchboard);
  117.     
  118.     ((CCTBSwitchboard *)itsSwitchboard)->ICTBSwitchboard();
  119. }
  120.  
  121.  
  122. /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
  123.  
  124. /*
  125.  * Process1Event
  126.  *
  127.  * Handle the next Event
  128.  *
  129.  */        
  130.         
  131. void CCTBApp::Process1Event(void)
  132. {
  133.     #ifdef __USETHREADS__
  134.     if (threadManagerPresent)
  135.         ThreadBeginCritical();
  136.     #endif
  137.  
  138.     #ifdef __USETHREADS__
  139.     if (! threadManagerPresent)
  140.     {
  141.     #endif
  142.     
  143.         CConnection::cConnIdle();        /* Idle loop for connection objects */
  144.  
  145.         CTermPane::cTermIdle();            /* Idle loop for terminal objects */
  146.     
  147.         CFileTransfer::cFTransIdle();    /* Idle loop for transfer objects */
  148.         
  149.     #ifdef __USETHREADS__
  150.     }
  151.     #endif
  152.     
  153.     inherited::Process1Event();        /* Send the message to its superclass */
  154.     
  155.     #ifdef __USETHREADS__
  156.     if (threadManagerPresent)
  157.     {
  158.         ThreadEndCritical();
  159.         YieldToAnyThread();
  160.     }
  161.     #endif
  162. }    
  163.  
  164.  
  165. /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
  166.  
  167. /*
  168.  * GetCTBVersions
  169.  *
  170.  * Return the CTB managers versions
  171.  *
  172.  * CTBVers:        CommToolbox version
  173.  * CMVers:        Connection Manager version
  174.  * TMVers:        Terminal Manager version
  175.  * FTVers:        File Transfer Manager version
  176.  * CRMVers:        Communications Resources Manager version
  177.  *
  178.  */
  179.  
  180. void CCTBApp::GetCTBVersions(short *CTBVers,short *CMVers,short *TMVers,
  181.                                 short *FTVers,short *CRMVers)
  182. {
  183.     *CTBVers = CTBGetCTBVersion();
  184.     *CRMVers = CRMGetCRMVersion();
  185.     
  186.     *CMVers = CConnection::cGetCMVersion();
  187.     *TMVers = CTermPane::cGetTMVersion();
  188.     *FTVers = CFileTransfer::cGetFTVersion();
  189. }
  190.  
  191.  
  192. /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
  193.  
  194. /*
  195.  * managersPresent
  196.  *
  197.  * Are the CTB managers installed ?
  198.  *
  199.  * Return TRUE if all managers are present
  200.  *
  201.  */
  202.  
  203. Boolean CCTBApp::managersPresent(void)
  204. {
  205.     if (TrapAvailable(CTB_TRAP))
  206.         return TRUE;
  207.     else
  208.         return FALSE;
  209. }
  210.  
  211.  
  212. /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
  213.